package physicshandler;

import java.awt.*;

public class PhysXProcessor
{
	int positionX, positionY;
	double dx, dy, objectSize;
	boolean gravity = false, deadItem = false;

	private Toolkit toolkit = Toolkit.getDefaultToolkit();
	private Dimension dim   = toolkit.getScreenSize();
	public double getDx() {
		return dx;
	}

	public void setDx(double dx) {
		this.dx = dx;
	}

	public double getDy() {
		return dy;
	}

	public void setDy(double dy) {
		this.dy = dy;
	}


	public int getPositionX() {
		return positionX;
	}

	public void setPositionX(int positionX) {
		this.positionX = positionX;
	}

	public int getPositionY() {
		return positionY;
	}

	public void setPositionY(int positionY) {
		this.positionY = positionY;
	}


	public boolean isGravity() {
		return gravity;
	}

	public void setGravity(boolean gravity) {
		this.gravity = gravity;
	}

	public PhysXProcessor(int positionX, int positionY) 
	{
		this.positionX = positionX;
		this.positionY = positionY;
	}
	
	public PhysXProcessor(int positionX, int positionY, int diameter) 
	{
		// TODO Auto-generated constructor stub
		this.positionX = positionX;
		this.positionY = positionY;
		objectSize = diameter;
	}

	public void handleEvents()
	{
		handleYAxisEvents();
		handleXAxisEvents();
		applyChanges();
	}
	
	private void handleXAxisEvents() {
		// TODO Auto-generated method stub
		if (positionX >= (int) (dim.getWidth() - objectSize) ||
			positionX <= 0)
		{
			dx = dx * (-1);
		}
		
		
	}

	private void handleYAxisEvents() {
		// TODO Auto-generated method stub
		if (positionY != (int) (dim.getHeight() - objectSize))
		{
			if (gravity)
			{
				dy += .098;
				
			}	
			if (positionY >= dim.getHeight() - objectSize)
			{
				dy = (dy * (-1)) / 1.7;
			}
		}
		
	}

	public boolean isDeadItem() {
		return deadItem;
	}

	public void setDeadItem(boolean deadItem) {
		this.deadItem = deadItem;
	}

	private void applyChanges()
	{
		positionX += dx;
		positionY += dy;
	}


	

}
